package com.lishe.lishe.lishe.module.coupon.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;
import java.util.ArrayList;

/**
 * Created by Bin on 2017/8/11.
 */

public class CouponPagerAdaper extends FragmentPagerAdapter {

    ArrayList<Fragment> lisFragments;
    String[] titles;

    public CouponPagerAdaper(ArrayList<Fragment> lisFragments, String[] titles, FragmentManager fm) {
        super(fm);
        this.lisFragments = lisFragments;
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return lisFragments.get(position);
    }

    @Override
    public int getCount() {
        return lisFragments == null ? 0 : lisFragments.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }


    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (titles == null) {
            return super.getPageTitle(position);
        }
        return titles[position];
    }
}
